package cn.mxz.generator.config;

import java.util.ArrayList;
import java.util.List;

import cn.mxz.generator.util.StringUtils;

public class InterfaceImpl implements IInterface {

	private String name;
	
	private List<IMethod> methods;
	
	public InterfaceImpl(String name) {
		this.name = name;
		this.methods = new ArrayList<IMethod>();
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public IMethod getMethod(String methodName) {
		for (IMethod m : methods) {
			if(m.getName().equals(methodName)) {
				return m;
			}
		}
		throw new IllegalArgumentException(methodName + "在" + name + "中没有找到");
	}
	
	@Override
	public void addMethod(IMethod method) {
		this.methods.add(method);
	}

	@Override
	public String getBeanName() {
		return StringUtils.firstToLowerCase(name);
	}

	@Override
	public String getInterfaceName() {
		return name;
	}
}
